# Tanım: Güçlü ve gelişmiş bir tarayıcı.
# URL: https://vivaldi.com
# Paketçi: Cihan_Alkan
# Gerekler: gtk3 libcups nss gconf alsa-lib libxss ttf-font desktop-file-utils shared-mime-info hicolor-icon-theme w3m
# Grup: ağ

isim=vivaldi
surum=1.15.1147.47
devir=1
kaynak=(https://downloads.vivaldi.com/stable/vivaldi-stable-${surum}-1.x86_64.rpm)

derle() {
    cp -a {opt,usr} "$PKG"

    # suid sandbox
    chmod 4755 "$PKG/opt/vivaldi/vivaldi-sandbox"

    # make /usr/bin/vivaldi-stable available
    binf="$PKG/usr/bin/vivaldi-stable"
    if [[ ! -e "$binf" ]] && [[ ! -f "$binf" ]] && [[ ! -L "$binf" ]]; then
        install -dm755 "$PKG/usr/bin"
        ln -s /opt/vivaldi/vivaldi "$binf"
    fi

    # install icons
    for res in 16 22 24 32 48 64 128 256; do
        install -Dm644 "$PKG/opt/vivaldi/product_logo_${res}.png" \
            "$PKG/usr/share/icons/hicolor/${res}x${res}/apps/vivaldi.png"
    done

    # license
    install -dm755 "$PKG/usr/share/licenses/$isim"
    strings "$PKG/opt/vivaldi/locales/en-US.pak" \
        | tr '\n' ' ' \
        | sed -rne 's/.*(<html lang.*>.*html>).*/\1/p' \
        | w3m -I 'utf-8' -T 'text/html' \
        > "$PKG/usr/share/licenses/$isim/eula.txt"
}